package com.example.rabbitmq.demo1_modes.consumer.mode02_work;

import com.example.rabbitmq.enums.RabbitmqQueueNamesEnum;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;


/**
 * @Author songyahui
 * @Date 2023/7/7 8:15
 * @Description
 */
public class WorkQueueConsumer {


    public static void consumeMessageWithWorkMode(Channel channel) throws IOException {
        //消息接受时处理
        DeliverCallback deliverCallback = (consumerTag, message)->{
            System.out.println("消费消息："+ new String(message.getBody()));
        };
        //取消消费时处理
        CancelCallback cancelCallback = System.out::print;
        channel.basicConsume(RabbitmqQueueNamesEnum.QUEUE_NAME_WORK.queueName, true, deliverCallback, cancelCallback);
    }

}
